package edu.tju.dorm;

import java.sql.SQLException;

import java.util.List;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.younker.waf.db.IBatisConfig;


public class IbatisPavilionDao implements IPavilionDao{
	protected SqlMapClient sqlMap = IBatisConfig.getSqlMapInstance();

	
	public void deletePavilion(long id) throws SQLException {
		
		sqlMap.delete("deletePavilion", id);
	}

	@SuppressWarnings("unchecked")
	
	public List<Pavilion> getPavilionAnd(Pavilion pavilion) throws SQLException {
		
		return sqlMap.queryForList("getPavilionAnd", pavilion);
	}

	
	public Pavilion getPavilionById(long id) throws SQLException {
		
		return (Pavilion) sqlMap.queryForObject("getPavilionById", id);
	}

	
	public List<Pavilion> getPavilionOr(Pavilion pavilion) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	
	public Long insertPavilion(Pavilion pavilion) throws SQLException {
		
		return (Long)sqlMap.insert("insertPavilion", pavilion); 
	}

	
	public int updatePavilion(Pavilion pavilion) throws SQLException {
		
		return sqlMap.update("updatePavilion", pavilion);
	}

}
